<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        //1.定义基本格式
        var person = {"name": "张三", age: 23, 'gender': true};

        var ps = [{"name": "张三", "age": 23, "gender": true},
            {"name": "李四", "age": 24, "gender": true},
            {"name": "王五", "age": 25, "gender": false}];




        //获取person对象中所有的键和值
        //for in 循环
       /* for(var key in person){
            //这样的方式获取不行。因为相当于  person."name"
            //alert(key + ":" + person.key);
            alert(key+":"+person[key]);
        }*/

       //获取ps中的所有值
        for (var i = 0; i < ps.length; i++) {
            var p = ps[i];
            for(var key in p){
                alert(key+":"+p[key]);
            }
        }

    </script>

</head>
<body>

</body>
</html>